const db = require("../config/config");
module.exports = {
  //根据用户id，，获取该用户购物车信息
  getMemberInfo(req, res) {
    db.dbMysql(`SELECT * FROM user`, [], function (err, data) {
      console.log(data, "data");
      for (let i = 0; i < data.length; i++) {
        if (data[i].user_enable == 0) {
          data[i].user_enable = true;
        } else {
          data[i].user_enable = false;
        }
      }
      for (let i = 0; i < data.length; i++) {
        if (data[i].user_type == 1) {
          data[i].user_type = "管理员";
        } else if (data[i].user_type == 2) {
          data[i].user_type = "成员";
        } else if (data[i].user_type == 3) {
          data[i].user_type = "用户";
        }
      }
      if (data) {
        res.send({
          code: 200,
          data: data,
          msg: "角色管理查询成功",
        });
      } else {
        res.send({
          code: 500,
          msg: "服务器错误",
        });
      }
    });
  },
};
